package map;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @Author Justin Parker
 * @Date 2024/7/22 0022 14:41
 * @Version 1.0
 */
public class MapDemo02 {
    public static void main(String[] args){
        HashMap<String,Integer> map = new HashMap<>();
        map.put("剑圣",200);
        map.put("盖伦",150);
        map.put("亚托克斯",175);
        System.out.println(map);

        Set<String> keys = map.keySet();
        for(String key:keys){
            System.out.println(key);
        }

        Collection<Integer> values = map.values();
        for(Integer value:values){
            System.out.println(value);
        }

        Set<Map.Entry<String,Integer>> entries = map.entrySet();
        for (Map.Entry<String,Integer> entry:entries){
            System.out.println(entry);
        }

        map.forEach((k,v)->{
            System.out.println(k+"-->"+v);
        });

    }
}
